//
//  SuccessView.swift
//  SwiftUiBaseStudy
//
//  Created by Daniel on 2023/12/26.
//

import SwiftUI
import Lottie

struct SuccessView: View {
    @State var show = false
    
    var body: some View {
        VStack {
            Text("Logging you...")
                .font(.title)
                .bold()
                .animation(.linear(duration: 1)
                    .delay(0.2), value: show)
                
            LottieView(animation: .named("success"))
                .playing()
                .frame(width:300,height:300)
                .opacity(show ? 1:0)
                .animation(.linear(duration: 1)
                    .delay(0.4), value: show)
        }
        .padding(.top,20)
        .background(BlurView(style: .systemMaterial))
        .clipShape(RoundedRectangle(cornerRadius: 20, style: .continuous))
        .shadow(color: .black.opacity(0.2),radius: 30,x:0,y:30)
        .scaleEffect(show ? 1:0.5)
        .animation(.spring(response: 0.5,dampingFraction: 0.6), value: show)
        .onAppear{
            show = true
        }
        .frame(maxWidth: .infinity,maxHeight: .infinity)
        .background(.black.opacity(0.2))
        .animation(.linear(duration: 0.5), value: show)
    }
}

#Preview {
    SuccessView()
}
